#pragma once
//-------------------------------------------------------------------------------------------------
//PropertiesWnd.h : CPropertiesToolBar and CPropertiesWnd classes         
//-------------------------------------------------------------------------------------------------
//FreeBSD License
//Copyright 2011 Will Stott All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice, this list of
//      conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice, this list
//      of conditions and the following disclaimer in the documentation and/or other materials
//      provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Will Stott ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Will Stott OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Will Stott.
//
//----Authors--------------------------------------------------------------------------------------
//created by: will.stott@ucl.ac.uk July 2011
//
//----Comments-------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------

#include "ArchiveProcGUIDoc.h"

#include "ImageProps.h"
#include "ImageObjectTypeTool.h"

class CPropertiesToolBar : public CMFCToolBar
{
public:
	virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler)
	{
		CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler);
	}

	virtual BOOL AllowShowOnList() const { return FALSE; }
};

class CPropertiesWnd : public CDockablePane
{
	DECLARE_DYNAMIC( CPropertiesWnd )

public:
	static const int ImageObjNoteDisplayLength = 25;	
// Construction
public:
	CPropertiesWnd();

	void AdjustLayout();

// Attributes
public:
	void SetVSDotNetLook(BOOL bSet)
	{
		m_wndImageObjectPropList.SetVSDotNetLook(bSet);
		m_wndImageObjectPropList.SetGroupNameFullWidth(bSet);
	}

protected:
	CFont m_fntBoldPropList;
	CFont m_fntPropList;

	CStatic	m_ImageDicomRefCtrl;
	CString m_ImageDicomRef;
	CStatic	m_ImageBrightnessHeaderCtrl;
	CSliderCtrl m_ImageBrightnessCtrl;
	CStatic	m_ImageContrastHeaderCtrl;
	CSliderCtrl m_ImageContrastCtrl;
	CComboBox m_wndImageTypeCombo;
	CStatic	m_ImageNotesHeaderCtrl;
	CEdit	m_ImageNotesCtrl;
	CString m_ImageNotes;
	CMFCPropertyGridCtrl m_wndImagePropList;

	CStatic	m_SeperatorCtrl;

	CStatic	m_ImageObjectHeaderCtrl;
	CComboBox m_wndImageObjectCombo;
	CStatic	m_ImageObjectNotesHeaderCtrl;
	CEdit	m_ImageObjectNotesCtrl;
	CString m_ImageObjectNotes;
	CMFCPropertyGridCtrl m_wndImageObjectPropList;

private:
	int	   m_ctrlComboHt;	
	int	   m_ctrlMinHeaderHt;
	int	   m_ctrlSliderHt;
	bool   m_UpdatingUI;
	int	   m_cxSize;
	int	   m_cySize;
	CRect  m_ClientRect;
	ImageObject *m_pSelImageObject;

public:
	virtual ~CPropertiesWnd();

protected:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnExpandAllProperties();
	afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnThumbChangeBrightness(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnThumbChangeContrast(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnImageTypeDropDown();
	afx_msg void OnImageTypeSelChange();
	afx_msg void OnImageObjectSelChange();
	DECLARE_MESSAGE_MAP()

public:
	afx_msg void OnEditCut();
	afx_msg void OnEditCopy();
	afx_msg void OnEditPaste();

	void   LoadProperties(ImageProps *pProps, ImageObjectTypeTool *pTool, ImageDataset *pImageDataset);
	bool   SaveProperties(ImageProps *pSelImageProps);
	void   UpdateProperties(ImageProps *pProps, int lHint);

private:
	ImageProps  *GetSelImageProperties() { return CArchiveProcGUIDoc::GetActiveDoc()->GetSelImageProperties(); }

	bool	LoadImageTypeCB(ImageProps *pSelImageProps, ImageDataset *pImageDataset);
	bool    LoadImageProperties(ImageProps *pSelImageProps);
	bool    SaveImageProperties(ImageProps *pSelImageProps);
	void    ClearImageDisplay();
	bool    SetImageDisplay(ImageProps *pImageProps);

	bool	SelectImageObjectCB(ImageObject *pSelImageObject);
	bool    LoadImageObjectCB(ImageProps *pSelImageProps, ImageObjectTypeTool *pTool);
	bool    LoadImageObjectProperties(ImageProps *pSelImageProps);
	bool    SaveImageObjectProperties(ImageProps *pSelImageProps);
	void    ClearImageObjectDisplay();
	void    SetImageObjectDisplay(ImageObject *pSelImageObject);

	void	SetFontForControls();

	void	CancelImageTypeSelChange();
	void	CancelImageObjectSelChange();

	virtual void DoDataExchange(CDataExchange* pDX);



};

//-------------------------------------------------------------------------------------------------
//			E N D   O F   F I L E
//-------------------------------------------------------------------------------------------------
